<%--
  Created by IntelliJ IDEA.
  User: desire
  Date: 2022/4/27
  Time: 23:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<input type="button" value="提交JSON数据" onclick="fun1();">
<script type="text/javascript">
    function fun1(){
        $.ajax({
            type: 'POST',
            url: "get",
            contentType: "application/json",//如果想以json格式把数据提交到后台的话，这个必须有，否则只会当做表单提交
        data:
            JSON.stringify({"id":"1213","name":"还好"}),//JSON.stringify()必须有,否则只会当做表单的格式提交
        dataType: "json",//期待返回的数据类型
            success: function(data){
            alert("success:"+data);
        },
        error:function(data){
            alert("error"+data);
        }
    });
    }
</script>
</body>
</html>
